package ms.unicorn.erml;

import ms.unicorn.modellanguage.IModelLanguage;
import ms.unicorn.modellanguage.LanguageElement;
import ms.unicorn.modellanguage.LanguageEntity;
import ms.unicorn.modellanguage.LanguageRelation;
import ms.unicorn.modellanguage.ModelLanguage;

public class ERML extends ModelLanguage implements IModelLanguage {

	public static final String UNICORN_LANGUAGE_ID = "erml";
	
	public static final String REQUIREMENT_ID = "erml.requirement";
	public static final String COMPOSITION_HUB_ID = "erml.dhub";
	public static final String COMPOSITION_ID = "erml.composition";
	public static final String SUBPART_ID = "erml.subpart";
	public static final String SUBPART_COMPARTMENT_ID = "erml.subpart.compartment";
	public static final String ACTOR_ID = "erml.actor";
	public static final String ACTOR_COMPARTMENT_ID = "erml.actor.compartment";
	
	public static LanguageEntity Requirement;
	public static LanguageEntity CompositionHub;
	public static LanguageRelation Composition;
	public static LanguageEntity SubPart;
	public static LanguageEntity SubPartCompartment;
	public static LanguageEntity Actor;
	public static LanguageEntity ActorCompartment;
	
	public static ERML INSTANCE;
	
	public ERML() {
		if (INSTANCE == null)
			INSTANCE = this;
		
		registerBuiltinElements();
	}
		
	
	private void registerBuiltinElements() {
		addElement(createSubpartCompartment());
		addElement(createActorCompartment());
	}

	private LanguageElement createActorCompartment() {
		LanguageEntity e = new LanguageEntity(this);
		e.setId(ACTOR_COMPARTMENT_ID);
		e.setName("Actor Compartment");
		return e;
	}


	private LanguageElement createSubpartCompartment() {
		LanguageEntity e = new LanguageEntity(this);
		e.setId(SUBPART_COMPARTMENT_ID);
		e.setName("Subpart Compartment");
		return e;
	}

	@Override
	public void registerElementTypes() {
		super.registerElementTypes();
		
		Requirement = (LanguageEntity) getElement(REQUIREMENT_ID);
		CompositionHub = (LanguageEntity) getElement(COMPOSITION_HUB_ID);
		Composition = (LanguageRelation) getElement(COMPOSITION_ID);
		SubPart = (LanguageEntity) getElement(SUBPART_ID);
		SubPartCompartment = (LanguageEntity) getElement(SUBPART_COMPARTMENT_ID);
		Actor = (LanguageEntity) getElement(ACTOR_ID);
		ActorCompartment = (LanguageEntity) getElement(ACTOR_COMPARTMENT_ID);
	}

}
